<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button id="btn">发送ajax表单</button>

<script>
    let btn = document.querySelector("#btn")
    btn.onclick = function () {
        let xhr = new XMLHttpRequest()
        console.log(xhr.readyState)
        xhr.open('get', 'http://localhost:8080')
        console.log(xhr.readyState)
        xhr.send()
        xhr.onreadystatechange = function () {
            // console.log(xhr.readyState)
            if (xhr.readyState === 4) {
                if (xhr.status >= 200 && xhr.status < 300) {
                    console.log(xhr.responseText)
                }
            }
        }
    };
</script>
</body>
</html>